#include<iostream>
#include<vector>
#include<string>

using namespace std;

struct TreeNode {
	int val;
	TreeNode *left;
	TreeNode *right;
	TreeNode() : val(0), left(nullptr), right(nullptr) {}
	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
	TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
	
};

class Solution {
public:
	vector<int> result;
	void midIteration(TreeNode *node) {
		if (!node)
			return;
		midIteration(node->left);
		result.push_back(node->val);
		midIteration(node->right);
	}

	int kthSmallest(TreeNode* root, int k) {
		midIteration(root);
		return result[k - 1];
	}
};

int main() {

}